package com.baymx.plugin.demo

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import com.bytedance.scene.Scene
import com.bytedance.scene.ktx.requireNavigationScene
import com.ysten.tv.plugin.impl.PluginModuleFactoryImpl

class PluginScene : Scene() {
    override fun onCreateView(p0: LayoutInflater, p1: ViewGroup, p2: Bundle?): View {
        return p1.newSceneFlexContainer {
            addButton("plugin test") {
                background = PluginModuleFactoryImpl.PContent.getDrawable(R.drawable.shape)
                Toast.makeText(requireActivity(), "plugin from plugin1", Toast.LENGTH_SHORT).show()
            }
            addButton("plugin push") {
                requireNavigationScene().push(DemoScene())
            }
            addButton("plugin push2") {
                requireNavigationScene().push(DemoScene2())
            }


        }
    }

    class DemoScene : Scene() {
        override fun onCreateView(p0: LayoutInflater, p1: ViewGroup, p2: Bundle?): View {
            return p1.newSceneFlexContainer {
                addButton("hello world")
            }
        }
    }
    class DemoScene2 : Scene() {
        override fun onCreateView(p0: LayoutInflater, p1: ViewGroup, p2: Bundle?): View {
            return   LayoutInflater.from(PluginModuleFactoryImpl.PContent).inflate(R.layout.test ,null)
        }
    }

}